//
// Copyright (C) 2008, 2009
// Barcelona Supercomputing Center - Centro Nacional de Supercomputacion
// Universitat Politecnica de Catalunya
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//

#ifndef _CONFIGPARAMETER_HPP
#define _CONFIGPARAMETER_HPP

#include <stdint.h>
#include <vector>
#include <string>

class ConfigParameter {
    private:
    int _option;
    uint32_t _chips;
    uint32_t _threadsInChip;
    int _apps;
    std::vector<std::string> _dirname;
    std::vector <int> _threads;
    uint32_t _pageSize;
    uint32_t _lineSize,_L0Size,_L1Size,_L2Size;
    uint32_t _L1Prefetch;
    uint32_t _L1TLBSize,_L2TLBSize,_L1TLBAssoc,_L2TLBAssoc;
    bool _L2Shared;
    uint32_t _migrate,_threshold,_InterChipThreshold;
    uint32_t _pagesInRange;
    uint32_t _L0invalidatePolicy,_victimPolicy;
    uint32_t _LMOption,_LMSize;
    uint32_t _MultiFELI_policy;
    bool _skipwrite;
    bool _traceIterations;

    uint32_t _tid;

    public:
        ConfigParameter(){
            /* default parameters */
            _chips=1;
            _threadsInChip=1;
            _apps=1;
            _lineSize=_L0Size=_L1Size=_L2Size=0;
            _L1Prefetch=0;
            _L1TLBSize=128;
            _L2TLBSize=0;
            _L1TLBAssoc=_L2TLBAssoc=4;
            _L2Shared=false;
            _migrate=0;
            _threshold=2;
            _L0invalidatePolicy=_victimPolicy=0;
            _LMSize=0;
            _pagesInRange=0;
            _pageSize=4096;
            _skipwrite=false;
            _traceIterations=0;
        };
        ~ConfigParameter(){};
        inline void setOption(int option) {_option=option;}
        inline int getOption() {return _option;}

        inline std::string getDirname(int app) { return _dirname[app];}
        inline void setDirname(std::string appName) {_dirname.push_back(appName);}

        inline uint32_t getTraceIterations(){return _traceIterations;}
        inline void  setTraceIterations(uint32_t traceIterations){_traceIterations=traceIterations;}

        inline void setNumberChips(uint32_t chips) {_chips=chips;}
        inline uint32_t getNumberChips(void) {return _chips;}

        inline void setNumberThreadsInChip(uint32_t threads) {_threadsInChip=threads;}
        inline uint32_t getNumberthreadsInChip(void) {return _threadsInChip;}

        inline int getNumberApps(void) {return _apps;}
        inline void setNumberApps(int apps) {_apps=apps;}

        inline int getThreads(int app) { return _threads[app];}
        inline void setThreads(int threads) {_threads.push_back(threads);}

        int getTotalThreads() {
            return _chips*_threadsInChip;
        }

        inline uint32_t getPageSize(void) {return _pageSize;}
        inline void setPageSize(uint32_t pagesize) {_pageSize=pagesize;}

        /* Cache Sizes */

        inline uint32_t getLineSize(void) {return _lineSize;}
        inline void setLineSize(uint32_t linesize) {_lineSize=linesize;}

        inline uint32_t getL0Size(void) {return _L0Size;}
        inline void setL0Size(uint32_t l0size) {_L0Size=l0size;}

        inline uint32_t getL1Size(void) {return _L1Size;}
        inline void setL1Size(uint32_t l1size) {_L1Size=l1size;}

        inline uint32_t getL2Size(void) {return _L2Size;}
        inline void setL2Size(uint32_t l2size) {_L2Size=l2size;}

        inline bool getL2Shared(void) {return _L2Shared;}
        inline void setL2Shared(uint32_t l2shared) {_L2Shared=l2shared;}

        /*Prefecthers*/

        inline uint32_t getL1Prefetch(void) {return _L1Prefetch;}
        inline void setL1Prefetch(uint32_t l1prefetch) {_L1Prefetch=l1prefetch;}

        /* TLB Sizes and Associativity */
        inline uint32_t getTLB1Size(void) {return _L1TLBSize;}
        inline void setTLB1Size(uint32_t l1tlbsize) {_L1TLBSize=l1tlbsize;}

        inline uint32_t getTLB1Assoc(void) {return _L1TLBAssoc;}
        inline void setTLB1Assoc(uint32_t l1tlbassoc) {_L1TLBAssoc=l1tlbassoc;}

        inline uint32_t getTLB2Size(void) {return _L2TLBSize;}
        inline void setTLB2Size(uint32_t l2tlbsize) {_L2TLBSize=l2tlbsize;}

        inline uint32_t getTLB2Assoc(void) {return _L2TLBAssoc;}
        inline void setTLB2Assoc(uint32_t l2tlbassoc) {_L2TLBAssoc=l2tlbassoc;}

        /* Migration Paramters */

        inline uint32_t getMigrate(void) {return _migrate;}
        inline void setMigrate(uint32_t migrate) {_migrate=migrate;}

        inline uint32_t getThreshold(void) {return _threshold;}
        inline void setThreshold(uint32_t threshold) {_threshold=threshold;}

        inline uint32_t getPagesInRange(void) {return _pagesInRange;}
        inline void setPagesInRange(uint32_t pagesInRange) {_pagesInRange=pagesInRange;}

        /* Policies */

        inline uint32_t getL0InvalidatePolicy(void) {return _L0invalidatePolicy;}
        inline void setL0InvalidatePolicy(uint32_t L0invalidatePolicy) {_L0invalidatePolicy=L0invalidatePolicy;}

        inline uint32_t getVictimPolicy(void) {return _victimPolicy;}
        inline void setVictimPolicy(uint32_t victimPolicy) {_victimPolicy=victimPolicy;}

        /* LPartition Size and Option to evaluate*/
        /* Size is in pages*/
        inline uint32_t getLMSize(void) {return _LMSize;}
        inline void setLMSize(uint32_t lmsize) {_LMSize=lmsize;}

        inline uint32_t getLMOption(void) {return _LMOption;}
        inline void setLMOption(uint32_t lmoption) {_LMOption=lmoption;}

        inline uint32_t getMultiFELIPolicy(void) {return _MultiFELI_policy;}
        inline void setMultiFELIPolicy(uint32_t policy) {_MultiFELI_policy=policy;}

        inline uint32_t getInterChipThreshold(void) {return _InterChipThreshold;}
        inline void setInterChipThreshold(uint32_t threshold) {_InterChipThreshold=threshold;}

        /* Skip Write operations from Trace Files*/
        inline bool getSkipWrite(void) {return _skipwrite;}
        inline void setSkipWrite(bool skipwrite) {_skipwrite=skipwrite;}

        /* Others */
        inline bool getTid(void) {return _tid;}
        inline void setTid(int tid) {_tid=tid;}
     };

#endif
